<template>
  <el-dropdown trigger="click" @command="handleSetSize" size="medium">
    <i class="iconfont icon-more-2" z-index="2" style="font-size: 20px;"></i>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="size==='medium'" command="medium">Medium</el-dropdown-item>
      <el-dropdown-item :disabled="size==='small'" command="small">Small</el-dropdown-item>
      <el-dropdown-item :disabled="size==='mini'" command="mini">Mini</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
  export default {
    computed: {
      size () {
        return this.$store.getters.size
      }
    },
    methods: {
      handleSetSize (size) {
        this.$ELEMENT.size = size
        this.$store.dispatch('setSize', size)
        this.refreshView()
        this.$message({
          message: '元素大小设置成功，请稍后！',
          type: 'success'
        })
      },
      refreshView () {
        this.$nextTick(() => {
          this.$router.go(0)
        })
      }
    }

  }
</script>

